package org.example.struct.array;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liyishan
 * @date 2024/1/3 10:23
 * @apiNote
 */

public class Test00598MaxCount {
    public static void main(String[] args) {
        int[][] ops = {};
        System.out.println(maxCount(3, 3, ops));
    }

    public static int maxCount(int m, int n, int[][] ops) {
        int[][] arrs = new int[m][n];
        for (int[] op : ops) {
            int x = op[0], y = op[1];
            for (int i = 0; i < x; i++) {
                for(int j = 0; j < y; j++){
                    arrs[i][j]++;
                }
            }
        }
        Map<Integer,Integer> map = new HashMap<>();
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                map.put(arrs[i][j],map.getOrDefault(arrs[i][j],0)+1);
            }
        }
        int max = 0;
        for(Map.Entry<Integer,Integer> entry : map.entrySet()){
            max =  Math.max(max,entry.getKey());
        }
        return map.get(max);
    }

    public int maxCount1(int m, int n, int[][] ops) {
        int mina = m, minb = n;
        for(int[] op : ops){
            mina = Math.min(mina, op[0]);
            minb = Math.min(minb, op[1]);
        }
        return mina * minb;
    }
}
